<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<div id="app">
  <h2>{{fullName}}</h2>
</div>
<script>
  const app = new Vue({
    el: "#app",
    data:{
      message:"Hello zk I am Vue !",
      firstName:'zhuang',
      lastName:'kang'
    },
    computed:{
      //不加动词，计算属性，以属性命名
      //语法糖，简写
      /*fullName() {
        return this.firstName+" "+this.lastName;
      }*/
      fullName:{
        //属性中get方法不适用，只是一个只读属性
        set(newValue){
          console.log('-->',newValue);
          const names=newValue.split('');
          this.firstName=names[0];
          this.firstName=names[1];
        },
        get(){
          return this.firstName+" "+this.lastName
        }
      }
    }
  })
</script>
</body>
</html>
